package com.example.qxfw.qxybzz.service.Impl;

import com.example.qxfw.common.SysResult;
import com.example.qxfw.qxybzz.entity.PageBean;
import com.example.qxfw.qxybzz.entity.dto.StrategyDto;
import com.example.qxfw.qxybzz.entity.vo.Strategy;
import com.example.qxfw.qxybzz.mapper.PublishStrategyMapper;
import com.example.qxfw.qxybzz.service.PublishStrategyService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Service
@RequiredArgsConstructor
public class PublishStrategyServiceImpl implements PublishStrategyService {

    private final PublishStrategyMapper publishStrategyMapper;

    @Override
    public PageBean getPageStrategy(Integer page, Integer pageSize) {
        PageHelper.startPage(page, pageSize);

        List<Strategy> strategy =publishStrategyMapper.getPageStrategy();
        Page<Strategy> pageStrategy = (Page<Strategy>) strategy;

        PageBean pageBean = new PageBean(pageStrategy.getTotal(), pageStrategy.getResult());
        return pageBean;

    }

    @Override
    public void deleteStrategy(Integer id) {
        publishStrategyMapper.deleteStrategy(id);
    }

    @Override
    public void updateStrategy(StrategyDto strategy) {
        publishStrategyMapper.updateStrategy(strategy);
    }

    @Override
    public void addStrategy(StrategyDto strategy) {
        publishStrategyMapper.addStrategy(strategy);
    }


}
